package astoliarskyi.wicket.card.restriction;

import java.util.Calendar;

public class TripNumber extends RestrictionContainer{

	public enum TripNumberType {
	
		T5(5), T10(10), NO_TRIP_NUMBER_RESTRICTION(-1);
		
		private final int standartTripNumber;
		
		private TripNumberType(int tripNumber) {
			this.standartTripNumber = tripNumber;
		}

		public int getStandartTripNumber() {
			return standartTripNumber;
		}
	}

	private final TripNumberType tripNumberType;
	private int tripsLeft;

	public TripNumber(TripNumberType tripNumberType) {
		if (tripNumberType == null) {
			throw new IllegalArgumentException();
		} else {
			tripsLeft = tripNumberType.getStandartTripNumber();
			this.tripNumberType = tripNumberType;
		}
	}

	@Override
	public boolean checkout(Calendar dateToday) {
		if (tripsLeft > 0) {
			tripsLeft = tripsLeft - 1;
			return true;
		} else {
			return false;
		}
	}

	@Override
	public TripNumberType getTripNumberType() {
		return tripNumberType;
	}
	
	@Override
	public int getTripsLeft() {
		return tripsLeft;
	}

	@Override
	public Term.TermType getTermType() {
		return Term.TermType.NO_TERM;
	}
}
